1. Authentication & Endpoint
All requests to the Lyzr Voice API require anx-api-key header containing your organization’s API key.
- Production Base URL:
https://voice-livekit.studio.lyzr.ai - Authentication Header:
x-api-key: <YOUR_LYZR_API_KEY>
2. Integration Flow
The integration follows a four-step lifecycle: session initialization, WebRTC connection, active streaming, and cleanup.Step 1: Start a Session
Initialize a session via a REST call. This dispatches a voice agent to a unique room and generates access credentials for the client.- Endpoint:
POST /v1/session/start - Request Body:
- Response: Returns a
userToken,roomName, andurl(LiveKit server URL).
Step 2: Connect to Agent Room
Use the returnedurl and userToken to join the real-time session using a LiveKit compatible SDK.
Step 3: Stream Audio
Once the connection is established, publish your local microphone track. The agent will automatically subscribe to your audio and respond with high-fidelity audio and transcription data events.Step 4: End Session
To ensure the agent is successfully released and resources are cleaned up, explicitly terminate the session.- Endpoint:
POST /v1/session/end - Body:
{ "roomName": "the-room-name-from-step-1" }
3. Reference Implementation (React/TypeScript)
The following implementation snippets provide a robust foundation for integrating the voice agent into a web application.A. API Client Configuration
This wrapper ensures all calls are authenticated and pointed to the correct production environment.B. Background Audio Renderer
Lyzr agents publish a dedicated track namedbackground_audio for ambient noise and “thinking” sound effects. Because standard room renderers often ignore unknown track names, you must manually attach this track to an audio element.